<?php
    require_once "config.php";
    $serv = new swoole_server("127.0.0.1",9501);

    $serv->set([
        'worker_num'=>2,
        'max_request'=>1000
    ]);

    // binding and listening the event on the server side
/**
 *  $fd .client id
 *
 */
    $serv->on(CONNECT_EVENT,function($serv,$fd,$reactor_id){
        echo "Client: {$fd} -- {$reactor_id} connected \n";
    });

    $serv->on(RECEIVE_EVENT,function($serv,$fd,$reactor_id,$data){
        $serv->send($fd,'Swoole '.":{$fd}->{$reactor_id}".$data."\n");
     //   $serv->close($fd);
    });

    $serv->on(CLOSE_EVENT,function($serv,$fd){
        echo "Client {$fd} Close \n";

    });

    $serv->start();
